package com.huidao.service;

import com.huidao.dao.FunctionDao;
import com.huidao.dao.FunctionDaoImpl;

public class FunctionServiceImpl implements FunctionService {
	
	FunctionDao dao = new FunctionDaoImpl();
	public String addFunction(Long roleId,String[] menuIds) {
		//判断之前是否添加过权限
		boolean isAdded = dao.checkFunction(roleId);
		if(isAdded){//添加过
			if(dao.delFunction(roleId)){//删除之前所选的权限
				if(dao.addFunction(roleId,menuIds)){//添加新的权限列表
					return "";
				}
			}
		}else{
			if(dao.addFunction(roleId,menuIds)){
				return "";
			}
		}
		return "权限设置失败";
	}

	@Override
	public boolean isFunction(Long roleId, String url) {
		// TODO Auto-generated method stub
		return dao.isFunction(roleId, url);
	}
}
